﻿@{
    ViewBag.Title = "Take";
}
@{
  var userValid = 0;

foreach (var User in ViewBag.Proctors)
{
    if (User.Name == ViewBag.Username)
    {
        userValid = 1;
        break;
    }
}

if (userValid == 1) {

<h2 id="surveyName" >Survey: @ViewBag.SurveyModel.Name</h2>
<h5>By: @ViewBag.SurveyModel.Originator</h5>

<script src="@Url.Content("~/Scripts/takesurvey.js")" type="text/javascript"></script>

    <div class="accordion" id="responsesAccordion">

    @if (ViewBag.Questions != null)
    {

        foreach (var question in ViewBag.Questions)
        {
         <div class="accordion-group" id="questionAccordion">
            <div class="accordion-heading" id="questionHeader">
              <a id = "questionText" class="accordion-toggle" data-toggle="collapse" data-parent="#responsesAccordion" href="#@question.Id">
                @question.Question
              </a>
            </div>
            <div id="@question.Id" class="accordion-body collapse">
              <div id="bodyOfResponse" class="accordion-inner">
                @if (question.Type == 1) {//response as text
                    <input id="responseText @question.Id" onPaste="return false" onkeyup="delayFunction(saveTextResponse(@question.Id,@ViewBag.sessionId), 500)"  type="text" placeholder="Please enter response here…"/>
                } else { //response as multiple choice or true/false
                     if (question.Choices != null)
                     {
                         int counter = 0;
                         <div class="btn-group" data-toggle="buttons-radio">
                        @foreach (var choice in question.Choices)
                        {
                            <button type="button" class="btn btn-info" id="responseChoice @question.Id @counter" onmouseup="delayFunction(saveRadioResponse(@question.Id, @ViewBag.sessionId, @counter),500)" title="@choice.Choice">@choice.Choice</button>
                            counter++;
                        }
                        </div>
                    }
                }
              </div>
            </div>
          </div>
        }
    }

</div>
<div>
    <button type="button" class="btn btn-success" id="submitAction">Submit Survey</button>
</div>

<div class="modal fade hide in" id="getPPIDModal" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
            ×</button>
        <h3 id="myModalLabel">
            Enter PayPal ID</h3>
    </div>
    <div class="modal-body">
    @using (Html.BeginForm())
    {
        <fieldset>
             <div class="editor-label">
               <label>If you would like to be paid, please enter your Email Address. Else, hit cancel</label>
            </div>
            <div class="editor-field">
                <input type="text" id="paypalIDField" placeholder="Enter email address here..."/>
                <span class="help-block">If you already have PayPal, use that email address here.</span>
            </div>
        </fieldset>
    }
    </div>
    <div class="modal-footer">
        <button id="submitDialogButton" class="btn btn-success" data-dismiss="modal">Submit</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
    </div>
</div>

    if (ViewBag.SurveyModel.Monetized)
{
    <script type="text/javascript">        showModal()</script>
}

}
}